<template>
  <div class="chat-panel">
    <div class="content">
      <template v-for="(message, index) in currentMessageList">
        <left-bubble v-if="message.msgFrom === currentChatUser.account" :message="message" :src=currentChatUser.avatar
                     :key="index"/>
        <right-bubble v-if="message.msgTo === currentChatUser.account" :message="message" :src=$store.state.user.avatar
                      :key="index"/>
      </template>
    </div>
  </div>
</template>

<script>
import LeftBubble from './LeftBubble'
import RightBubble from './RightBubble'

export default {
  name: 'ChatPanel',
  components: {
    LeftBubble,
    RightBubble
  },
  props: {
    currentChatUser: Object,
    currentMessageList: Array
  },
  watch: {
    currentChatUser () {
      console.log('ChatPanel-currentChatUser:', this.currentChatUser)
    }
  }
}
</script>

<style lang="stylus" scoped>
  .chat-panel {
    height: 500px;
    overflow-x hidden
    overflow-y auto
  }
</style>
